package demo.controller.webFlux;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.reactive.function.server.RequestPredicates;
import org.springframework.web.reactive.function.server.RouterFunction;
import org.springframework.web.reactive.function.server.RouterFunctions;
import org.springframework.web.reactive.function.server.ServerResponse;
import reactor.core.publisher.Mono;

/**
 * 配置类用于定义应用程序的全局配置，例如 WebFlux 的路由配置、自定义 Bean 等。
 */
@Configuration
public class HelloRouter {


    @Bean
    public RouterFunction<ServerResponse> routes() {
        return RouterFunctions.route(RequestPredicates.GET("/hello"),
                request -> ServerResponse.ok()
                        .body(Mono.just("Hello, WebFlux!"), String.class)
        );
    }
}
